<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>代码生成</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" href="/ant/static/css/layui.css">
    <link rel="stylesheet" href="/ant/static/css/common.css">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title">
    <legend>生成数据表代码</legend>
</fieldset>

<div class="center">
    <form class="layui-form layui-form-pane" action="/ant/create/save" style="margin-top: 10px;">

        <div class="layui-form-item">
            <div class="layui-col-xs5">
                <div class="layui-form-item left">
                    <label class="layui-form-label font-color">数据库名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="databaseName" lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${createSet.databaseName}">
                    </div>
                </div>
            </div>

            <div class="layui-col-xs5">
                <div class="layui-form-item left">
                    <label class="layui-form-label font-color">表名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="tableNames" lay-verify="required"
                               autocomplete="off" class="layui-input" th:value="${createSet.tableNames}">
                    </div>
                </div>
            </div>

            <div class="layui-col-xs5">
                <div class="layui-form-item left">
                    <label class="layui-form-label font-color">代码生成路径</label>
                    <div class="layui-input-block">
                        <input type="text" name="codePackage" lay-verify="required" placeholder="src/main/java/com/ant/business/other/"
                               autocomplete="off" class="layui-input" th:value="${createSet.codePackage}">
                    </div>
                </div>
            </div>

            <div class="layui-col-xs5">
                <div class="layui-form-item left">
                    <label class="layui-form-label font-color">包路径</label>
                    <div class="layui-input-block">
                        <input type="text" name="allPackage" lay-verify="required" placeholder="com.ant.business.other."
                               autocomplete="off" class="layui-input" th:value="${createSet.allPackage}">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block" style="margin-left: 100px;">
                    <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="module">提交</button>
                    <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                </div>
            </div>
        </div>
    </form>
</div>
<script src="/ant/static/layui.all.js"></script>
<script src="/ant/static/common.js"></script>
<script src="/ant/static/jQuery/jquery-2.2.3.min.js"></script>

<script>
    layui.use(['form', 'layedit'], function () {
        var form = layui.form;
        var layer = layui.layer;
        var $ = layui.$;

        //监听提交
        form.on('submit(module)', function (data) {
            var json = data.field;
            showLoading(true);
            $.ajax({
                type: 'POST',
                url: prefix + '/create/save',
                data: json,
                success: function (data) {
                    showLoading(false);
                    if (data.code === 700) {
                        layer.alert('代码生成成功',
                            {
                                title: '代码生成',
                                btn: ['确定']
                            },
                            /*function (index, item) {
                                window.parent.location.reload();
                                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(index);
                            }*/
                        );
                    } else {
                        var msg = data.msg;
                        if (msg === '' || msg === null || msg === undefined) {
                            msg = '代码生成出错';
                        }
                        layer.alert(msg, {
                            title: '代码生成'
                        })
                    }
                },
                error: function (data) {
                    var msg = data.msg;
                    if (msg === '' || msg === null || msg === undefined) {
                        msg = '后台连接出现异常，请重试';
                    }
                    showLoading(false);
                    layer.alert(msg, {
                        title: '代码生成警告'
                    })
                }
            });

            return false;
        });
    });
</script>

</body>
</html>